﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyLib {
	/// <summary>
	/// 
	/// </summary>
	public static class ValidationRules {
		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v"></param>
		public static void NotEmpty(string title, string v) {
			if (string.IsNullOrEmpty(v)) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentEmpty, title));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v"></param>
		public static void NotWhiteSpace(string title, string v) {
			if (string.IsNullOrWhiteSpace(v)) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentWhiteSpace, title));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LegalRange(string title, int? v1, int? v2) {
			if (v1.HasValue && v2.HasValue) {
				if (v1.Value > v2.Value) {
					throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentIllegalRange, title));
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LegalRange(string title, long? v1, long? v2) {
			if (v1.HasValue && v2.HasValue) {
				if (v1.Value > v2.Value) {
					throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentIllegalRange, title));
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LegalRange(string title, decimal? v1, decimal? v2) {
			if (v1.HasValue && v2.HasValue) {
				if (v1.Value > v2.Value) {
					throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentIllegalRange, title));
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LegalRange(string title, double? v1, double? v2) {
			if (v1.HasValue && v2.HasValue) {
				if (v1.Value > v2.Value) {
					throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentIllegalRange, title));
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LegalRange(string title, DateTime? v1, DateTime? v2) {
			if (v1.HasValue && v2.HasValue) {
				if (v1.Value > v2.Value) {
					throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentIllegalRange, title));
				}
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThan(string title, int v1, int v2) {
			if (v1 <= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThanOrEqual(string title, int v1, int v2) {
			if (v1 < v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThan(string title, int v1, int v2) {
			if (v1 >= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThanOrEqual(string title, int v1, int v2) {
			if (v1 > v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void Equal(string title, int v1, int v2) {
			if (v1 != v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void NotEqual(string title, int v1, int v2) {
			if (v1 == v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThan(string title, long v1, long v2) {
			if (v1 <= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThanOrEqual(string title, long v1, long v2) {
			if (v1 < v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThan(string title, long v1, long v2) {
			if (v1 >= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThanOrEqual(string title, long v1, long v2) {
			if (v1 > v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void Equal(string title, long v1, long v2) {
			if (v1 != v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void NotEqual(string title, long v1, long v2) {
			if (v1 == v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThan(string title, double v1, double v2) {
			if (v1 <= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThanOrEqual(string title, double v1, double v2) {
			if (v1 < v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThan(string title, double v1, double v2) {
			if (v1 >= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThanOrEqual(string title, double v1, double v2) {
			if (v1 > v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void Equal(string title, double v1, double v2) {
			if (v1 != v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void NotEqual(string title, double v1, double v2) {
			if (v1 == v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThan(string title, decimal v1, decimal v2) {
			if (v1 <= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThanOrEqual(string title, decimal v1, decimal v2) {
			if (v1 < v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThan(string title, decimal v1, decimal v2) {
			if (v1 >= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThanOrEqual(string title, decimal v1, decimal v2) {
			if (v1 > v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void Equal(string title, decimal v1, decimal v2) {
			if (v1 != v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void NotEqual(string title, decimal v1, decimal v2) {
			if (v1 == v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThan(string title, DateTime v1, DateTime v2) {
			if (v1 <= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void GreatThanOrEqual(string title, DateTime v1, DateTime v2) {
			if (v1 < v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotGreatThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThan(string title, DateTime v1, DateTime v2) {
			if (v1 >= v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThan, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void LessThanOrEqual(string title, DateTime v1, DateTime v2) {
			if (v1 > v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotLessThanOrEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void Equal(string title, DateTime v1, DateTime v2) {
			if (v1 != v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentNotEqual, title, v2));
			}
		}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="title"></param>
		/// <param name="v1"></param>
		/// <param name="v2"></param>
		public static void NotEqual(string title, DateTime v1, DateTime v2) {
			if (v1 == v2) {
				throw new ApplicationException(string.Format(Properties.Main.ErrorArgumentEqual, title, v2));
			}
		}
	} // end of ValidationRules.
}
